import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { id } from 'element-plus/es/locale';

/**
 * 获取仓库列表
 */
export function getStockroomList(data:any) {
  return request({
    url: '/api/wms/stockroom',
    method: 'get',
    params: data
  });
}
/**
 * 获取仓库列表
 */
export function getStockroomSelectList(data:any) {
  return request({
    url: '/api/wms/stockroom/select',
    method: 'get',
    params: data
  });
}


/**
 * 获取新增仓库列表
 */
export function getStockroomCreate(data:any) {
  return request({
    url: '/api/wms/stockroom/create',
    method: 'get',
    params: data
  });
}

/**
 * 获取编辑仓库
 */
export function getStockroomEdit(data:any) {
  return request({
    url: '/api/wms/stockroom/'+ data.id+'/edit',
    method: 'get'
  });
}
/**
 * 删除仓库
 */
export function getStockroomDel(data:any) {
  return request({
    url: '/api/wms/stockroom/'+data.id,
    method: 'delete',
    data:data
  });
}


/**
 * 搜索列表
 */
export function getStockroomHeader(data:any) {
  return request({
    url: '/api/wms/stockroom/header',
    method: 'get'
  });
}



/**
 * 请求一个接口 不甜字段不添加参数不添加类型
 */
export function useRequestAny(data:any) {
  
  if(data.method == "POST" || data.method == "PUT")
  {
    return request({
      url: '/api'+data.url,
      method: data.method,
      data:data.data
    });
  }
  else
  {
    return request({
      url: '/api'+data.url,
      method: data.method,
      params: data.data,
    });
  }
}

/**
 * 仓位列表
 */
export function getPositionList(data:any) {
  return request({
    url: '/api/wms/position',
    method: 'get',
    params:data
  });
}

/**
 * 获取新增仓库列表
 */
export function getPositionCreate(data:any) {
  return request({
    url: '/api/wms/position/create',
    method: 'get',
    params: data
  });
}
/**
 * 获取编辑仓位表单
 */
export function getPositionEdit(data:any) {
  return request({
    url: '/api/wms/position/'+ data.id+'/edit',
    method: 'get'
  });
}

/**
 * 获取编辑仓位表单
 */
export function getPositionDel(data:any) {
  return request({
    url: '/api/wms/position',
    method: 'delete',
    data:data
  });
}

/**
 * 物品列表 
 */
export function getGoodsList(data:any) {
  return request({
    url: '/api/wms/goods',
    method: 'get',
    params:data
  });
}
/**
 * 物品详情
 */

export function getGoodsDetail(data:any) {
  return request({
    url: '/api/wms/goods/' + data.id,
    method: 'get'
  });
}

/**
 * 删除物品
 */
export function getGoodsDel(data:any) {
  return request({
    url: '/api/wms/goods',
    method: 'delete',
    params:data
  });
}
/**
 * 编辑物品
 */
export function getGoodsEdit(data:any) {
  return request({
    url: '/api/wms/goods',
    method: 'put',
    data:data
  });
}

/**
 * 获取新增物品表单
 */
export function getGoodsCreate(data:any) {
  return request({
    url: '/api/wms/goods/create',
    method: 'get',
    data:data
  });
}
/**
 * 获取编辑物品表单
 */
export function getGoodsFormEdit(data:any) {
  return request({
    url: '/api/wms/goods/'+data.id+'/edit',
    method: 'get'
  });
}
/**
 * 导出物品表
 */
export function getGoodsExport(data:any) {
  return request({
    url: '/api/wms/goods/export',
    method: 'get',
    params:data,
    responseType: 'arraybuffer'
  });
}

/**
 * 入库单列表
 */
export function getInboundList(data:any) {
  return request({
    url: '/api/wms/inbound',
    method: 'get',
    params:data
  });
}
/**
 * 入库
 */
export function getInboundAdd(data:any) {
  return request({
    url: '/api/wms/inbound',
    method: 'post',
    data:data
  });
}
/**
 * 仓库下拉选择
 * */
export function getStockroomOptions(data:any) {
  return request({
    url: '/wms/stockroom/options',
    method: 'get',
    params:data
  });
}
/**
 * 获取仓位下拉选择列表
 */
export function getPositionOptions(data:any) {
  return request({
    url: '/wms/position/options',
    method: 'get',
    params:data
  });
}
/**
 * 物品选择列表
 */
export function getGoodsOptions(data:any) {
  return request({
    url: 'wms/goods/options',
    method: 'get',
    params:data
  });
}
/**
 * 入库单详情
 */
export function getInbound(data:any) {
  return request({
    url: 'wms/inbound/' + data.id,
    method: 'get'
  });
}


/**
 * 出库单列表
 */
export function getOutboundList(data:any) {
  return request({
    url: 'wms/outbound',
    method: 'get',
    params:data
  });
}

/**
 * 仓库中物品选择
 */
export function getGoodsSelect(data:any) {
  return request({
    url: 'wms/goods/select',
    method: 'get',
    params:data
  });
}

/**
 * 出库
 */
export function getOutboundAdd(data:any) {
  return request({
    url: 'wms/outbound',
    method: 'post',
    data:data
  });
}
/**
 * 出库单详情
 */
export function getOutbound(data:any) {
  return request({
    url: 'wms/outbound/'+data.id,
    method: 'get'
  });
}


/**
 * 调拨单列表
 */
export function getAllotList(data:any) {
  return request({
    url: 'wms/allot',
    method: 'get',
    params:data
  });
}

/**
 * 调拨单详情
 */
export function getAllotDetail(data:any) {
  return request({
    url: 'wms/allot/'+data.id,
    method: 'get'
  });
}
/**
 * 新建调拨单
 */
export function getAllotAdd(data:any) {
  return request({
    url: 'wms/allot',
    method: 'post',
    data:data
  });
}
/**
 * 变更记录 
 */
export function getStockLog(data:any) {
  return request({
    url: 'wms/stock/log',
    method: 'get',
    params:data
  });
}
/**
 * 获取物品库存列表
 */
export function getStockList(data:any) {
  return request({
    url: 'wms/stock',
    method: 'get',
    params:data
  });
}



/**
 * 盘点单列表
 */
export function getStocktakingList(data:any) {
  return request({
    url: 'wms/stocktaking',
    method: 'get',
    params:data
  });
}
/**
 * 新建盘点单
 */
export function getStocktakingAdd(data:any) {
  return request({
    url: 'wms/stocktaking',
    method: 'post',
    data:data
  });
}
/**
 * 编辑盘点单
 */
export function getStocktakingEdit(data:any) {
  return request({
    url: 'wms/stocktaking/' + data.id,
    method: 'put',
    data:data
  });
}
/**
 * 盘点单详情表 
 */
export function getStocktakingDetail(data:any) {
  return request({
    url: 'wms/stocktaking/' + data.id,
    method: 'get',
  });
}
/**
 * 盘点
 */
export function getStocktakingCheck(data:any) {
  return request({
    url: 'wms/stocktaking/check/' + data.id,
    method: 'put',
    data:data
  });
}
